package com.ptmall.app.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.ptmall.app.App;
import com.ptmall.app.AppApplication;
import com.ptmall.app.MainActivity;
import com.ptmall.app.R;
import com.ptmall.app.base.BaseMvpActivity;
import com.ptmall.app.bean.model.db.Account;
import com.ptmall.app.bean.model.db.DBHelper;
import com.ptmall.app.bean.model.db.dao.AccountDao;
import com.ptmall.app.net.HttpMethods;
import com.ptmall.app.utils.SharedPreferenceUtil;
import com.ptmall.app.view.TitleBarView;

import java.util.List;


/**
 * Created by Administrator on 2018/10/12.
 */

public class SettingActivity extends BaseMvpActivity implements View.OnClickListener {

    Button loginout;

    TitleBarView titlebar;

    RelativeLayout meinfo,gy,paypass;

    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_setting);
    }

    @Override
    public void initViews() {
        meinfo = (RelativeLayout) findViewById(R.id.meinfo);
        gy = (RelativeLayout) findViewById(R.id.gy);
        paypass = (RelativeLayout) findViewById(R.id.paypass);
        titlebar = (TitleBarView) findViewById(R.id.titlebar);
        loginout = (Button) findViewById(R.id.loginout);
        loginout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                loginOut();
            }
        });
        titlebar.setOnTitleBarClickListener(new TitleBarView.TitleBarClickListener() {
            @Override
            public void leftClick() {
                finish();
            }

            @Override
            public void rightClick() {

            }
        });

        meinfo.setOnClickListener(this);
        gy.setOnClickListener(this);
        paypass.setOnClickListener(this);
    }

    @Override
    public void initEvents() {
        findViewById(R.id.resetpsd).setOnClickListener(this);
    }


    private void loginOut(){
        SharedPreferenceUtil.setSharedStringData(SettingActivity.this,"memberId","");
        MainActivity.MEMBERID = "";
        finish();
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.meinfo:
                intent = new Intent(getContext(),InfoActivity.class);
                startActivity(intent);
                break;
            case R.id.resetpsd:
                intent = new Intent(getContext(),RegisterPassActivity.class);
                startActivity(intent);
                break;
            case R.id.gy:

                Intent intent = new Intent(getContext(), WebActivity.class);
                intent.putExtra("title","关于我们");
                intent.putExtra("url", HttpMethods.BASE_URL+"Detail/intro");
                startActivity(intent);
                break;
            case R.id.paypass:

                Intent intent2 = new Intent(getContext(), PassActivity.class);
                startActivity(intent2);
                break;
        }
    }
}
